package com.example.demo1.entity;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

/**
 * 将Consumer类声明为Spring组件，使其能够被Spring容器自动扫描和管理
 */
@Component
/**
 * 消费者实体类，用于映射配置文件中以"consumer"为前缀的属性
 * 通过@ConfigurationProperties注解自动绑定配置属性
 */
@ConfigurationProperties(prefix = "consumer")
public class Consumer {
    // @Value("${consumer.username}")
    private String username;
    // @Value("${consumer.age}")
    private String age;
    // @Value("${consumer.hobby}")
    private String[] hobby;
    // @Value("${consumer.subject}")
    private List subject;

    @Override
    public String toString() {
        return "Consumer{" +
                "username='" + username + '\'' +
                ", age='" + age + '\'' +
                ", hobby=" + Arrays.toString(hobby) +
                ", subject=" + subject +
                '}';
    }



    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String[] getHobby() {
        return hobby;
    }

    public void setHobby(String[] hobby) {
        this.hobby = hobby;
    }

    public List getSubject() {
        return subject;
    }

    public void setSubject(List subject) {
        this.subject = subject;
    }


}
